import { Controller } from "../../mvc/core/Controller";
import { IView } from "../../mvc/interfaces/IView";
import { TWHuiModule } from "../../../modules/TWHuiModule";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { DataEvent } from "../events/DataEvent";
import { GameProxy } from "../mvc/GameProxy";
import { PulseSharedObject } from "../view/player/PulseSharedObject";
import { SharedObjectName } from "../view/common/defin/SharedObjectName";
//class TWHuiController
    
    export  class TWHuiController extends Controller
    {
       

        protected /* override */ initView(): IView
        {
            if (!this._tWHuiModule) 
            {
                this._tWHuiModule = new TWHuiModule();
            }
            return this._tWHuiModule;
        }

        protected /* override */ initServer(): void
        {
            Dispatcher.addEventListener(EventName.TWHui_GotoLink, this.onGotoLink);
            Dispatcher.addEventListener(EventName.LoginGameSuccess, this.onLoginGameSuccess);
            return;
        }

        /* internal  */onGotoLink(arg1: DataEvent): void
        {
            var loc1=int(arg1.data);
            if (loc1 != 1) 
            {
                GameProxy.twHui.visitSites(loc1);
            }
            return;
        }

        /* internal  */onLoginGameSuccess(arg1: DataEvent): void
        {
            this.judgeBrink();
            return;
        }

        /* internal  */judgeBrink(): void
        {
            if (!PulseSharedObject.isTodayNotTips(SharedObjectName.isVisitTWLink2) || !PulseSharedObject.isTodayNotTips(SharedObjectName.isVisitTWLink3)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.TWHui_NotHaveVisitAll));
            }
            return;
        }

        private /* var */_tWHuiModule: IView;
    }
